from viterbi import *
from mfcc import *


# MFCC
training_data = wav_to_mfcc("train")
print("TRAIN DATA MFCC DONE")
testing_data = wav_to_mfcc("test")
print("TEST DATA MFCC DONE")
# Dimension of Vector
DIM = 39

# state & model
num_of_state_start = 12
num_of_state_end = 15
num_of_model = 11
accuracy_rate = []

for num_of_state in range(num_of_state_start, num_of_state_end + 1):
    # Train HMM model
    mean,var,Aij = EM(training_data, DIM, num_of_model, num_of_state)
    # Test HMM model
    accuracy_rate.append(HMM_test(mean,var,Aij, testing_data))
    print("num of state: %s, the accuracy of HMM is :" % num_of_state, accuracy_rate[num_of_state - num_of_state_start])
